package com.ibeifeng.io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.List;

public class TestObjectInputStream {
	public static void main(String[] args) {
		ObjectInputStream ois = null;
		try {
			ois = new ObjectInputStream(new FileInputStream("D:\\Workspaces\\temp\\student.data"));
//			Student stu = (Student)ois.readObject();
			List<Student> stus = (List<Student>)ois.readObject();
			for(Student stu : stus){
				System.out.println("id:"+stu.getId()+"--name:"+stu.getName());
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} finally{
			try {
				if(ois != null) ois.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}
}
